using Android.App;
using Android.OS;
using Android.Views;

namespace UnoSwipeControlTest.Droid;
[Activity(MainLauncher = true, ConfigurationChanges = ActivityHelper.AllConfigChanges, WindowSoftInputMode = SoftInput.AdjustNothing | SoftInput.StateHidden)]
public class MainActivity : ApplicationActivity
{
    protected override void OnCreate(Bundle? savedInstanceState)
    {
        AndroidX.Core.SplashScreen.SplashScreen.InstallSplashScreen(this);
        base.OnCreate(savedInstanceState);
    }
    public override void OnBackPressed()
    {
        if (App.MainFrame.CanGoBack)
        {
            App.MainFrame.GoBack();
        }
        else
        {
            AlertDialog? alert = new AlertDialog.Builder(this)
                .SetTitle("Exit")?
                .SetMessage("Are you sure you want to exit?？")?
                .SetPositiveButton("Exit", (s, e) => base.OnBackPressed())?
                .SetNegativeButton("Cancal", (s, e) => { })?
                .Create();
            if (alert is null)
            {
                base.OnBackPressed();
                return;
            }
            alert?.Show();
        }
    }
}
